<script setup>
import { ref, reactive, getCurrentInstance, onMounted, watch } from "vue"

const instance = getCurrentInstance()
const _this = instance.appContext.config.globalProperties //vue3获取当前this

// 组件中使用，接收传参的
let propsData = defineProps({
  list: {
    type: Array,
    required: true,
  },
  active: {
    type: String,
    default: 'Ambulance'
  },
  componentActive: {
    type: Number,
    default: 0
  },
})
// 组件中使用，接收事件的
const emits = defineEmits(['oneClick', 'twoClick']);

function totalClick1(item){
  emits('oneClick', item)
}
function totalClick2(item){
  emits('twoClick', item)
}
</script>
<template>
  <div class="total_info">
		<div class="total_info_bg"></div>
    <el-popover placement="right-end" :width="153" trigger="hover" v-for="(item, index) in list" :key="index">
      <template #reference>
        <div class="total_item" :class="active == item.label ? 'total_item_content_active' : ''"  @click="totalClick1(item)">
          <img v-if="active == item.label" :src="item.imgActiveSrc" alt="">
          <img v-else :src="item.imgSrc" alt="">
          <div class="total_item_content">
            <div class="f24">{{ item.value }}</div>
            <div>{{ item.label }}</div>
          </div>
        </div>
      </template>
      <div class="popover_list">
        <div class="total_item" style="width: 170px" :class="componentActive == popoverItem.componentActive ? 'total_item_content_active' : ''" v-for="(popoverItem, indexs) in item.popoverList" @click="totalClick2(popoverItem)" :key="indexs">
          <img v-if="componentActive == popoverItem.componentActive" :src="popoverItem.imgActiveSrc" alt="">
          <img v-else :src="popoverItem.imgSrc" alt="">
          <div class="total_item_content">
            <div class="f24">{{ popoverItem.value }}</div>
            <div>{{ popoverItem.label }}</div>
          </div>
        </div>
      </div>
    </el-popover>
	</div>
</template>
<style scoped lang='less'>
.total_info {
	position: fixed;
	left: 20px;
	top: 120px;
	width: 153px;
	height: 378px;
	padding: 10px 0;
	border-radius: 20px;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	// background-color: #ffffff;
	// backdrop-filter: blur(8px);
	z-index: 20;
	.total_info_bg{
		position: absolute;
		left: 0;
		top: 0;
		background-color: #fff;
    opacity: 0.8;
    width: 100%;
    height: 100%;
		border-radius: 20px;
    box-shadow: 0 0 20px #ccc;
	}

	.total_item {
		display: flex;
		flex-direction: row;
		align-items: center;
		cursor: pointer;
		padding: 0 10px;
		height: 19.5%;
		position: relative;
		img {
			width: 48px;
			height: 48px;
			margin-right: 14px;
		}

		.total_item_content {
			color: var(--mw-not-important-color);
      font-size: 12px;
			.f24 {
				font-size: 24px;
				color: var(--mw-font-color-content);
				line-height: 34px;
			}
		}
	}

	.total_item::after {
		content: '';
		display: block;
		width: 4px;
		height: 0;
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
		background-color: #3A4EFC;
		transition: height .3s ease;
	}

	.total_item::before {
		content: '';
		display: block;
		width: 100%;
		height: 0;
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
		background-color: rgba(58, 139, 252, 0.1);
		transition: height .3s ease;
	}

	.total_item:hover::after {
		height: 100%;
	}

	.total_item:hover::before {
		height: 100%;
	}

	.total_item_content_active {
		background-color: rgba(58, 139, 252, 0.1);
		color: var(--mw-tabs-menu-active-color) !important;
		position: relative;

		.f24 {
			color: var(--mw-tabs-menu-active-color) !important;
		}
	}

	.total_item_content_active::after {
		height: 100%;
	}
}
</style>